<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file='../share_header.jsp' %>
<div id="content-header">
    <h1>短信业务审核</h1>
</div>

<%--<div id="breadcrumb">--%>
<%--&lt;%&ndash;<a href="index.html" class="tip-bottom" data-original-title="Go to Home"><i class="icon-home"></i> Home</a>&ndash;%&gt;--%>
<%--<a href="javascript:void(0)"--%>
<%--url="${pageContext.request.contextPath}/crm/getMyselfClientInfo.do"  class="m-pageChange tip-bottom">客户信息管理</a>--%>
<%--<a href="javascript:void(0)"--%>
<%--url="${pageContext.request.contextPath}/crm/getMyselfClientInfo.do"  class="m-pageChange tip-bottom">我的客户</a>--%>
<%--<a href="#" class="current">短信业务审核</a>--%>
<%--</div>--%>
<div class="container-fluid marginTop20">
    <div class="row-fluid topCircleBorder paddingTop10 paddingBottom10 marginBottom5">
        <form class="form-horizontal" action="javascript:gotoPage(1)">
            <div class="form-group formLayOut">
                <div class="field">
                    <label for="messageSubmitter" class=" control-label">提交人</label>
                    <input class="text" type="text" id="messageSubmitter"/>
                </div>
            </div>
            <div class="form-group formLayOut">
                <div class="field">
                    <label for="messageBatch" class=" control-label">短信批次</label>
                    <input class="text" type="text" id="messageBatch"/>
                </div>
            </div>
            <div class="form-group formLayOut">
                <div class="field">
                    <label for="messageStatus" class=" control-label">短信状态</label>
                    <select id="messageStatus">
                        <option>已通过</option>
                    </select>
                </div>
            </div>
            <div class="form-group formLayOut marginLeft60">
                <div class="field">
                    <button id="searchMessageBtn" type="submit" class="btn btn-primary formButton">查询
                    </button>
                </div>
            </div>
        </form>
    </div>
    <div class="row-fluid">
        <table id="messageInfoTable">
        </table>

        <div class="formLayOut bottomMargin20">
            短信批次 第<input type="text" class="smallInputText no-margin" id="getMessageBatch">批
            <button type="button" class="btn btn-primary" id="checkMessage">开始审核
            </button>
        </div>
    </div>
</div>

<!-- Modal -->
<div id="showMessageModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3>审核短信内容</h3>
    </div>
    <div class="modal-body">

        <div class="container-fluid">
            <form class="form-horizontal">
                <fieldset>
                    <div>批次: <span class="fireText" id="messageBatchId">33</span></div>

                    <div class="textarea">
                        <textarea type="" style="width: 500px;height:260px" readonly> </textarea>
                    </div>

                </fieldset>
            </form>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="okAndSend">审核通过并发送
        </button>
        <button type="button" class="btn btn-primary" id="noToChange">驳回
        </button>
    </div>
</div>
<script src="${pageContext.request.contextPath}/resources/js/customer/checkMessage.js"></script>
<script>
    $(function () {
        gotoPage(1);
    });

    $("#checkMessage").click(function () {
        getMessageInfo($("#getMessageBatch").val());
    });

    var getMessageInfo = function (messageBatchm) {
        var url = "";
        var postData = {"messageBatch": messageBatchm};
        postAjax(url, postData, getMessageSuccess);

    }
    //编辑短信内容 获取内容成功 回调函数
    var getMessageSuccess = function (result) {
        //TODO init Page  给短信批次 和 短信内容赋值
//        var jsonData = $.parseJSON(result);
        $("#showMessageModal").modal("show");
    }

    //审核发送 成功关闭
    $("#okAndSend").click(function () {
        okAndSendMessage($("#messageBatchId").text());
    });

    var okAndSendMessage = function (messageBatch) {
        var url = "";
        var postData = {"messageBatch": messageBatch};
        postAjax(url, postData, okAndSendMessageSuccess);
    }

    var okAndSendMessageSuccess = function () {
        $("#showMessageModal").modal("hide");
    }

    //驳回 成功关闭
    $("#noToChange").click(function () {
        noToChangeMessage($("#messageBatchId").text());
    });

    var noToChangeMessage = function (messageBatch) {
        var url = "";
        var postData = {"messageBatch": messageBatch};
        postAjax(url, postData, noToChangeMessageSuccess);
    }

    var noToChangeMessageSuccess = function () {
        $("#showMessageModal").modal("hide");
    }

</script>

